/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div
      id="explanation"
      class="explanation"
      style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;"
    >
      <div class="bckopa-tips">
        <div class="title">
          <img src="@/static/images/handd.png" alt />
          <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        </div>
        <ul>
          <li>系统平台全局设置,包括基础设置、购物、短信、邮件、水印和分销等相关模块。</li>
        </ul>
      </div>
      <span title="收起提示" id="explanationZoom" style="display: block;"></span>
    </div>

    <el-form ref="form" :model="form" label-width="200px" label-position="right">
      <el-form-item label="选择短信平台">
        <el-radio-group v-model="form.sms_platform">
          <el-radio :label="'1'">阿里云</el-radio>
          <el-radio :label="'2'">天瑞云</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="短信平台[appkey]">
        <el-input v-model="form.sms_appkey" size="mini"></el-input>
        <p class="notic">短信平台配置appkey/keyid</p>
      </el-form-item>
      <el-form-item label="短信平台[secretKey]">
        <el-input v-model="form.sms_secretKey" size="mini"></el-input>
        <p class="notic">短信平台配置secretKey</p>
      </el-form-item>
      <el-form-item label="公司名/品牌名/产品名">
        <el-input v-model="form.sms_product" size="mini"></el-input>
      </el-form-item>
      <el-form-item label="用户注册时">
        <el-switch v-model="form.regis_sms_enable" active-value="1" inactive-value="0"></el-switch>
        <p class="notic">用户注册时使用短信验证、（修改手机验证、修改支付密码验证）</p>
      </el-form-item>
      <el-form-item label="用户找回密码时">
        <el-switch v-model="form.forget_pwd_sms_enable" active-value="1" inactive-value="0"></el-switch>
        <p class="notic">用户找回密码时使用短信验证</p>
      </el-form-item>
      <el-form-item label="身份验证时">
        <el-switch v-model="form.bind_mobile_sms_enable" active-value="1" inactive-value="0"></el-switch>
        <p class="notic">用户身份验证时使用短信验证</p>
      </el-form-item>
      <el-form-item label="用户下单时是否发送短信给商家">
        <el-switch v-model="form.order_add_sms_enable" active-value="1" inactive-value="0"></el-switch>
        <p class="notic">用户下单时是否发短信给商家</p>
      </el-form-item>
      <el-form-item label="客户支付时是否发短信给商家">
        <el-switch v-model="form.order_pay_sms_enable" active-value="1" inactive-value="0"></el-switch>
        <p class="notic">客户支付时是否发短信给商家</p>
      </el-form-item>
      <el-form-item label="商家发货时是否给客户发短信">
        <el-switch v-model="form.order_shipping_sms_enable" active-value="1" inactive-value="0"></el-switch>
        <p class="notic">商家发货时是否给客户发短信</p>
      </el-form-item>
      <el-form-item label="购买虚拟商品支付成功后,是否向用户发送短信">
        <el-switch v-model="form.virtual_goods_sms_enable" active-value="1" inactive-value="0"></el-switch>
        <p class="notic">用户购买虚拟商品在支付成功后, 发送短信给用户, 提示兑换码已生成</p>
      </el-form-item>
      <el-form-item label="短信码超时时间">
        <el-radio-group v-model="form.sms_time_out">
          <el-radio :label="'60'">1分钟</el-radio>
          <el-radio :label="'120'">2分钟</el-radio>
          <el-radio :label="'300'">5分钟</el-radio>
          <el-radio :label="'600'">10分钟</el-radio>
          <el-radio :label="'1200'">20分钟</el-radio>
          <el-radio :label="'1800'">30分钟</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit" :loading="subLoading">确认提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
	import {
		getConfigs,updateConfigs
	} from "@/utils/api"
export default {
  data() {
    return {
      form: {},
	  subLoading: false,
    };
  },
  created() {
    this.getConfigs();
  },
  methods: {
    getConfigs() {
      var that = this;
      getConfigs({inc_type: "sms"}).then(function(res) {
        that.form = res.sms;
      });
    },
    onSubmit() {
      var that = this;
	  that.subLoading = true
      updateConfigs('sms', that.form).then(function(res) {
		  that.subLoading = false
        if (res.status == 1) {
          that.$message.success("保存成功");
        } else {
          that.$message({
            showClose: true,
            message: "保存失败,失败原因:" + res.msg,
            type: "error"
          });
        }

      });
    }
  }
};
</script>
<style scoped>
	>>>.el-input--mini .el-input__inner {
		width: 300px;
	}
</style>
